<?php
	$site_news = array('id' => intval($_REQUEST['site_news_id']));
	
	if (local_post()) {
		$errors = array();
		if (empty($_POST['title'])) $errors[] = 'Please title the announcement.';
		
		if (!empty($errors)) errors($errors);
		else {
			$site_news['title'] = db_escape_string($_POST['title']);
			$site_news['html'] = db_escape_string($_POST['html']);
			
			$site_news = db_save($site_news, 'site_news');	
			
			if ($_POST['button'] == 'Save and Close') location('/site_news/admin/index');
			elseif ($_POST['button'] == 'Save and New') location('/site_news/admin/edit');
		}
	}
	
	$site_news = db_select($site_news['id'], 'site_news');
?>

<form action="?site_news_id=<?php echo $site_news['id']?>" method="post">
	<fieldset>
		<legend>Title</legend>
		
		<label for="title" style="width: 95%;">
			Title
			<input type="text" name="title" id="title" value="<?php echo $site_news['title']?>" style="width: 100%;" />
		</label>
	</fieldset>
	
	<fieldset>
		<legend>Announcement</legend>
	<?php
    $oFCKeditor = new FCKeditor("html");
    $oFCKeditor->BasePath = PHPDRIVER_WEB . 'plugins/fckeditor/';
    $oFCKeditor->Height = '500';
    $oFCKeditor->ToolbarSet = 'Default';
    $oFCKeditor->Value = $site_news['html'];
    $oFCKeditor->Create();			
	?>
	</fieldset>
	
	<?php save_buttons(); ?>
</form>